# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=crane
_pkgname=go-containerregistry
pkgver=0.16.1
pkgrel=1
pkgdesc="Interacting with remote container images and registries."
arch=('loong64' 'x86_64')
url="https://github.com/google/go-containerregistry"
license=('Apache-2.0')
makedepends=('go')
source=(https://github.com/google/${_pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('6b8d41175fda7497a90eb89a9b30d8291b418e1f9e524ae094439c9887fb06ac')
b2sums=('23e65a9d405dde7a6f5917e9a484bc93e7cd24136a18b0c71fd69b02538ec93afbad225c098eb0839b12412dce3d24227cf72bda38f59b73f3f3323a22f1f5b4')

build() {
  cd ${_pkgname}-${pkgver}

  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"

  go build ./cmd/crane
  go build ./cmd/gcrane

  cd cmd/krane
  go build .
}

package() {
  cd ${_pkgname}-${pkgver}
  install -Dm755 -t "${pkgdir}/usr/bin" \
    crane gcrane cmd/krane/krane
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et:
